package com.hackerrank.challenges.insertionsortpart2;

// Head ends here
import java.util.*;
public class Solution {

	static void insertionSort(int[] ar) {
		for(int j = 1; j < ar.length; j++) {
			int i = j, V = ar[j];
			for(; i > 0 && ar[i - 1] > V; i--)
				ar[i] = ar[i - 1];
			ar[i] = V;
			printArray(ar);
		}
	}

	// Tail starts here
	static void printArray(int[] ar) {
		for(int n: ar)
			System.out.print(n + " ");
		System.out.println("");
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ar = new int[n];
		for(int i=0;i<n;i++)
			ar[i]=in.nextInt();
		insertionSort(ar);
	}
}
